package org.komarichin.services;

import org.komarichin.beans.IComment;
import org.komarichin.beans.IGenericEntity;
import org.komarichin.beans.IHasComment;
import org.komarichin.beans.dao.ICommentDAO;
import org.komarichin.beans.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * <p>
 * &nbsp;
 * </p>
 * User: Michael Komarichin
 * Date: Mar 10, 2010
 * Time: 9:20:20 PM
 */
@Service
public class CommentService<PK> implements ICommentService<PK> {
    private static final long serialVersionUID = 1464802790592403455L;
    @Autowired
    private ICommentDAO<IComment<PK>, PK> commentDAO;


    @Override
    public IComment<PK> save(IComment<PK> comment) {
        return commentDAO.save(comment);
    }

    @Override
    public void saveOrUpdate(IComment<PK> comment) {
        commentDAO.saveOrUpdate(comment);
    }

    @Override
    public void remove(IComment<PK> comment) {
        commentDAO.remove(comment.getId());
    }

    @Override
    public void remove(PK id) {
        commentDAO.remove(id);
    }

    @Override
    public IComment<PK> findById(PK id) {
        return commentDAO.findById(id);
    }

    @Override
    public Collection<IComment<PK>> getCommentsForObject(Class<? extends IHasComment<IComment<PK>, IGenericEntity>> classObj, Object idValue) {
        return commentDAO.getCommentsForObject(classObj, idValue);
    }

    @Override
    public Collection<IComment<PK>> getCommentsForObject(IHasComment<IComment<PK>, IGenericEntity> obj) {
        return commentDAO.getCommentsForObject(obj);
    }

    @Override
    public Collection<IComment<PK>> getAll() {
        return commentDAO.getAll();
    }

    @Override
    public void assignCommentToObject(IHasComment<IComment<PK>, IGenericEntity> obj, IComment<PK> comment) {
        commentDAO.assignCommentToObject(obj, comment);
    }
}
